package scu.maqiang.meshgeneration;

import scu.maqiang.mesh.Mesh3T4;
import scu.maqiang.mesh.ScalarFunc;

public class RemoveElements {
    public static void main(String[] args) {
        //GenerageCrashedMesh();
        generageMicroMesh();
    }

    private static void GenerageCrashedMesh() {
        Mesh3T4 mesh3D = new Mesh3T4().cube(100, 100, 100);
        ScalarFunc region = (xyz, label, param) -> {
            double x = xyz[0];
            double y = xyz[1];
            double z = xyz[2];
            if (x * x + y * y + z * z < 0.25) {
                return 1.0;
            }else {
                return -1.0;
            }
        };
        mesh3D.removeElements(region, null, 10);
        mesh3D.toTecplot("CrashedMesh.dat");
    }

    public static void generageMicroMesh() {
        Mesh3T4 microMesh = new Mesh3T4().cube(3, 3, 3);
        ScalarFunc holeDomain = (xyz, label, param) -> {
            double x = xyz[0], y = xyz[1], z = xyz[2];
            boolean hole = Math.abs(x - 0.5) < 1.0 / 6 && Math.abs(y - 0.5) < 1.0/6 && Math.abs(z - 0.5) < 1.0 / 6;
            return hole?1.0:-1.0;
        };
        microMesh.removeElements(holeDomain, null, 10);
        microMesh.toTecplot("MicroMesh.dat");
        microMesh.displayNodes();
        //microMesh.displayElements();
        //microMesh.displayBoundarys();
        System.out.println(microMesh.getNv() + "  " + microMesh.getNt() + "  " + microMesh.getNb());
    }
}
